var hospitalInfo = new Vue({
    el:"#hospitalInfo",
    data:{
        hospitalPage:{},//医生信息
        hospitalDto:{},//医生信息
    },
    created:function(){
        var category=window.location.search;
         var id=category.substring(category.lastIndexOf("=")+1,category.length);
            var that = this;
            axios.get("/hospital//api/back/hospitala/select?hospitalId="+id).then(function(response){
                console.log(response)
                if (response.data.code!="0"){
                    alert(response.data.msg)
                    return;
                }
                that.hospitalPage = response.data.data.hospital;
                that.hospitalDto=response.data.data.hospitalDto;
             })
         }

})

    $(function(){
        $("#search").click(function(){
            var content=$("#content").val()
            if(content==""){
                alert("请输入查询数据")
            }else{
                get();
            }
        })
        function get(){
            var optinonid =$("option[class='dropdown-item']:selected").val();
            var category=window.location.search;
             var id=category.substring(category.lastIndexOf("=")+1,category.length);

        if(optinonid=="2"){
            var tdepartmentsName =$("#content").val();
                $.ajax({
                    type:"GET",
                    url:"/hospital/api/search/hospital",
                    data:{"hospitalId":id,"tdepartmentsName":tdepartmentsName},
                    dataType:"json",
                    success:function(data){
                        if(data.data!=""){
                            alert("科室id"+data.data[0].tdepartmentsId)
                        }else{
                            alert("该医院无此科室")
                        }

                    }
                })
        }else if(optinonid=="1"){
            var name =$("#content").val();
                $.ajax({
                    type:"GET",
                    url:"/hospital/api/search/hospital",
                    data:{"hospitalId":id,"name":name},
                    dataType:"json",
                    success:function(data){
                        if(data.data!=""){
                            alert("医生id"+data.data[0].doctorId)
                        }else{
                            alert("该医院无此医生")
                        }
                    }
                })
            }
        }
    })

    $(function(){
        var category=window.location.search;
         var id=category.substring(category.lastIndexOf("=")+1,category.length);
        $.ajax({
            type:"GET",
            url:"/hospital/api/select/hospital/departments",
            data:{"hospitalId":id},
            dataType:"json",
            async: false,
            success:function(data){
                for(var i=0;i<data.data.length;i++){
                    $("#Rendering").append(
                         "<div class='hospital-dep-item clearfix' >"+
                            "<div class='float-left'>"+data.data[i].departmentsName+"</div>"+
                            "<div class='float-left clearfix height160' style='height: 520px;' id =tdepartments"+[i+1]+">"+
                            "</div>"+
                         "</div>"+
                        "</div>"
                    )
                    var departmentsId=data.data[i].departmentsId;
                    tdepartments(departmentsId);
                }

            }
        })
        function tdepartments(departmentsId){
            $.ajax({
                type: "GET",
                url: "/hospital/api/tdepartments/select/hospital/tdepartments",
                data: {"hospitalId":id,"departmentsId":departmentsId},
                dataType: "json",
                async: false,
                success: function (data) {
                    console.log(data);
                    for(var i=0;i<data.data.length;i++){

                        $("#tdepartments"+departmentsId).append(
                            "<div class='float-left word-inline'>"+
                           "<a href=http://localhost:8080/hospital/page/department.html?hospitalId="+id+"&tdepartmentsId="+departmentsId+" target='_self' data-toggle='tooltip' data-placement='top' >"+data.data[i].tdepartmentsName+"</a>"+
                           "</div>"
                    )
                    }
                }
            })
            }

    })
var getTokenVue = new Vue({
    el:"#getToken",
    data:{
        token:localStorage.getItem("token")
    }
    ,methods:{

    }
})